package com.xywh.composeLibrary.statex

import androidx.compose.foundation.layout.BoxScope
import androidx.compose.runtime.Composable

/**
 * state-compose 全局配置
 * @author petterp
 */
object StateComposeConfig {
    internal var loadingComponent: @Composable (BoxScope.() -> Unit)? = null
    internal var emptyComponent: @Composable (BoxScope.(PageData.Empty, onClick: () -> Unit) -> Unit)? =
        null
    internal var errorComponent: @Composable (BoxScope.(PageData.Error, onClick: () -> Unit) -> Unit)? =
        null

    fun loadingComponent(component: @Composable (BoxScope.() -> Unit)? = null) {
        loadingComponent = component
    }

    fun errorComponent(component: @Composable (BoxScope.(PageData.Error, onClick: () -> Unit) -> Unit)? = null) {
        errorComponent = component
    }

    fun emptyComponent(component: @Composable (BoxScope.(PageData.Empty, onClick: () -> Unit) -> Unit)? = null) {
        emptyComponent = component
    }
}
